<?php
/**
 * @package WordPress
 * @subpackage MIP
 * @since MIP 1
 */
?>

<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if ( ! have_posts() ) : ?>
	<div id="post-0" class="post error404 not-found">
		<h1 class="entry-title"><?php _e( 'Not Found' ); ?></h1>
		<div class="entry-content">
			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.' ); ?></p>
			<?php get_search_form(); ?>
		</div><!-- .entry-content -->
	</div><!-- #post-0 -->
<?php endif; ?>

<?php while ( have_posts() ) : the_post(); ?>

<?php /* How to display all posts. */ ?>
		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

			<?php if(!is_search()){?>
			<div class="entry-meta">
			<div class="metadata"><span class="author"><?php  the_time('F j, Y') ?> | <?php _e(' Posted by');?> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) );?>"> <?php the_author();?></a> | <?php comments_popup_link(__('No Comments '), __('1 Comment '), __('% Comments ')); ?></span> </div>

			</div><!-- .entry-meta -->
			<?php } ?>

	<?php if (is_search() ) : // Only display excerpts for archives and search. ?>
			<div class="entry-summary">
				<?php $excerpt = get_the_excerpt(); echo ts_string_limit_words($excerpt,25);?>
			</div><!-- .entry-summary -->
	<?php else : ?>

			<div class="entry-content">
				<?php the_content( __( 'Read More' ) ); ?>
				<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:' ), 'after' => '</div>' ) ); ?>
				<div class="clr"></div><!-- end clear float -->
			</div><!-- .entry-content -->
			<div class="entry-utility">
				<?php
					$tags_list = get_the_tag_list( '', ', ' );
					if ( $tags_list ):
				?>
					<span class="tag-links">
						<?php printf( __( '<span class="%1$s">Tagged: </span> %2$s' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
					</span><br />
					<?php _e('Posted in:');?> <?php the_category(', ') ?><br />
				<?php endif; ?>
				<?php edit_post_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
			</div><!-- .entry-utility -->
	<?php endif; ?>

		</div><!-- #post-## -->

		<?php comments_template( '', true ); ?>

<?php endwhile; // End the loop. Whew. ?>


<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if (  $wp_query->max_num_pages > 1 ) : ?>
			 <?php if(function_exists('wp_pagenavi')) { ?>
				 <?php wp_pagenavi(); ?>
				 <br class="clr" />
			 <?php }else{ ?>
				<div id="nav-below" class="navigation">
					<div class="nav-previous"><?php next_posts_link( __( '<span class="prev"><span class="meta-nav">&laquo;</span> Older</span>' ) ); ?></div>
					<div class="nav-next"><?php previous_posts_link( __( '<span class="prev">Newer <span class="meta-nav">&raquo;</span></span>' ) ); ?></div>
				</div><!-- #nav-below -->

			<?php }?>
<?php endif; ?>

